<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateGamesTable extends Migration
{
    private $table = 'games';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('map_id',255)->comment('地图id');
            $table->unsignedInteger('winner_id')->default(0)->comment('赢得比赛的用户id');
            $table->unsignedInteger('win_coin')->default(0)->comment('奖励金币数');
            $table->unsignedInteger('win_diamond')->default(0)->comment('奖励钻石数');
            $table->tinyInteger('status')->comment('游戏状态：0.等待开始 1.进行中 2.结束');
            $table->tinyInteger('type')->default(1)->comment('游戏类型：1.1vs1 2.Tournament');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '游戏记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
